
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 1
 * @Author : WangRuoyu 
 * @Date : 2023/5/11 8:58
 */

#include "iostream"
#include "cstring"
#include "algorithm"

using namespace std;

int main() {
    int n;
    cin >> n;
    int nums[n];

    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
    }

    sort(nums, nums + n);

    int res = 0;

    for (int i = 0; i < n - 1; ++i) {
        if (nums[i + 1] - nums[i] == 1) {
            res++;
        }
    }

    cout << res;

    return 0;
}